<template>
  <div class="modal">
    <div class="box">
      <div class="text">{{msg}}</div>
      <!--  传递一个click事件    -->
      <el-button @click="emit('click')" type="primary">确定</el-button>
      <el-icon>
        <Close />
      </el-icon>
      <el-dialog
          v-model="dialogVisible"
          title="Tips"
          width="30%"
          :before-close="handleClose"
      >
        <span>{{msg}}</span>
        <template #footer>
      <span class="dialog-footer">
        <el-button @click="emit('click')">Cancel</el-button>
        <el-button type="primary" @click="emit('click')">
          Confirm
        </el-button>
      </span>
        </template>
      </el-dialog>
    </div>
  </div>
</template>

<script setup>
import { ref } from 'vue'
import { Close } from '@element-plus/icons'

// 定一个emit事件传递对象参数
const emit = defineEmits(['click'])

// 定一个字符串参数
defineProps({
  msg:{
    type:String,
    required:true
  },
})
</script>

<script>
export default {
  name:'',
  components:{

  },
  props:{

  },
  data() {
    return {
      dialogVisible:true,
    }
  },
  methods:{
    handleClose() {
      this.dialogVisible = false
      this.$emit('click')
    }
  }
}
</script>

<style scoped>
.modal{
  position: fixed;
  width: 100%;
  height: 100%;
  left: 0;
  top: 0;
  z-index: 999;
  background-color: #00000050;
  display: flex;
  justify-content: center;
  align-items: center;
}
</style>

